<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="com.pignest.hotel.spring.Services"%>
<%@page import="com.pignest.hotel.service.ReceptionService"%>
<%@page import="com.pignest.hotel.service.MemberService"%>
<%@page import="com.pignest.hotel.beans.Member" %>
<%@page import="com.pignest.hotel.beans.Living" %>
<%@page import="com.pignest.hotel.definition.OpenRoomType" %>
<%
String card = request.getParameter("card");
if (StringUtils.isEmpty(card)) {	// || card not exists
%>
<jsp:forward page="index.jsp"></jsp:forward>
<%
} else {
%>
<%
	request.setAttribute("index", 1);
	//如果有未结账的记录则将其转入退房页面
	MemberService ms =Services.getMemberService();
	String cardNumber =ms.queryCardNoBySerial(card);
	Member m=ms.queryMemberOnCard(cardNumber);
	if(m==null) {
%>
		<script type="text/javascript">
		alert('无效会员请联系请台管理员！',null, function(){
			window.location.href='index.jsp';
		});
		window.location.href='index.jsp';
		</script>
<%
	} else {
		ReceptionService rs=Services.getReceptionService();
		Living l =rs.getSelfMemberLiving(m);
		if(l!=null) {
//			out.print("<script type=\"text/javascript\">alert('当前有入住信息！还未退房请先退房再入住',null);</script>");
			String livingId =l.getId();
%>
			<jsp:include page="frame.jsp" ></jsp:include>
			<div id="selfhelpContent">
			<%
				 if(OpenRoomType.valueOf(l.getOpenRoomType()).name().equals(OpenRoomType.HOURS.name())){
				%>
				<iframe id="livingFrame"  width="100%" height="100%" frameborder="0" scrolling="no" src="hoursbackRoom.zul?livingId=<%=livingId%>"></iframe>
				<%}else if(OpenRoomType.valueOf(l.getOpenRoomType()).name().equals(OpenRoomType.HALFDAY.name())) {%>
				<iframe width="100%" height="100%" frameborder="0" scrolling="no" src="halfbackRoom.zul?livingId=<%=livingId%>"></iframe>
				<%}else { %>
				<iframe width="100%" height="100%" frameborder="0" scrolling="no" src="backRoom.zul?livingId=<%=livingId%>"></iframe>
				<%} %>
			</div>
<%
		} else {
%>
			<jsp:include page="frame.jsp" ></jsp:include>
			<div id="selfhelpContent">
			<iframe id="livingFrame" width="100%" height="100%" frameborder="0" scrolling="no" src="chooseRoom.zul?card=<%=card%>"></iframe>
			</div>
<%
		}
	}
}
%>
